package com.bupt.liutong.admin.sch.bo;

import java.util.List;

import com.bupt.liutong.util.FileUtils;
import com.bupt.liutong.util.StringUtils;
import com.bupt.liutong.admin.core.base.BaseBo;
import com.bupt.liutong.admin.sch.dao.TeacherPhotoDao;
import com.bupt.liutong.admin.sch.dto.TeacherPhoto;
import com.bupt.liutong.admin.sch.form.TeacherForm;

public class TeacherPhotoBo extends BaseBo {

	private TeacherPhotoDao teacherPhotoDao;
	
	public List<TeacherPhoto> getTeacherPhotos(TeacherForm teacherForm){
		return teacherPhotoDao.getTeacherPhotosByTeacherId(teacherForm.getId());
	}
	
//	public void deleteTeacherPhotoFiles(String[] filePaths){
//		for(String filePath:filePaths)
//			if (!StringUtils.isEmpty(filePath))
//				FileUtils.deleteFile(filePath);
//	}
	
	public void deleteTeacherPhotos(String[] ids) {
		if (ids != null) {
			for (String id : ids) {
				if (!StringUtils.isEmpty(id)) {
					TeacherPhoto teacherPhoto = teacherPhotoDao.getTeacherPhotoById(Integer.valueOf(id));
					teacherPhotoDao.deleteTeacherPhoto(Integer.valueOf(id));
					FileUtils.deleteFile(teacherPhoto.getFilePath());
				}
			}
		}
	}

	public void setTeacherPhotoDao(TeacherPhotoDao teacherPhotoDao) {
		this.teacherPhotoDao = teacherPhotoDao;
	}
}
